// Number
let pi = 3.1415926535;
// Boolean
let javascriptIsFun = true;
//  String
let currentJob = "programmer";
let introduction = "My job is a " + currentJob;
let introduction2 = `My job is a ${currentJob}`;
// undefined
let a = undefined;
// null
let obj = null;
// Symbol
let fooSymbol = Symbol("foo");
// BigInt
let bigNum1 = 9007199254740991n;
let bigNum2 = BigInt(9007199254740991);
// console.log(bigNum1 === bigNum2); // true

//数值转换
console.log(Number(true)); // 1
console.log(Number("")); // 0
console.log(Number("programmer")); // NaN
console.log(Number("123")); // 123
console.log(Number("100.25")); // 100.25
console.log(Number("0x12")); // 18
console.log(Number(a)); // NaN
console.log(Number(obj)); // 0
// console.log(Number(fooSymbol)); // 报错  Cannot convert a Symbol value to a number
console.log(Number(bigNum1)); // 9007199254740991
console.log(Number({})); // NaN

console.log(parseInt("1234blue")); //1234
console.log(parseInt("22.5")); // 22
console.log(parseInt("")); // NaN
console.log(parseInt(70)); // 70
console.log(parseInt("0xf")); // 15

console.log(parseInt("AF")); // NaN
console.log(parseInt("AF", 16)); // 175 按十六进制解析

console.log(parseInt("10", 2)); // 2 按二进制解析
console.log(parseInt("10", 8)); // 8 按八进制解析
console.log(parseInt("10", 10)); // 10 按十进制解析
console.log(parseInt("10", 16)); // 16 按十六进制解析

console.log(parseFloat("1234blue")); // 1234
console.log(parseFloat("0xA")); // 0
console.log(parseFloat("22.5")); // 22.5
console.log(parseFloat("22.34.5")); // 22.34
console.log(parseFloat("0908.5")); // 908.5
console.log(parseFloat("3.125e7")); // 31250000

function sumTag(strings, ...values) {
  console.log("Static parts:", strings);
  console.log("Dynamic values:", values);
  let result = undefined;
  for (const val of values) {
    result += values;
  }
  return result;
}
const num1 = 10;
const num2 = 15;
sumTag`The sum of ${num1} and ${num2} is ${num1 + num2}`;

let appleGlobalSymbol = Symbol.for("apple"); // 创建新符号
let otherAppleGlobalSymbol = Symbol.for("apple"); // 重用已有符号
console.log(appleGlobalSymbol === otherAppleGlobalSymbol); // true

const student = {
  name: "xiao ming",
  sex: "f",
};
// hasOwnProperty(propertyName)：用于判断当前对象实例（不是原型）上是否存在给定的属性。
console.log(student.hasOwnProperty("name")); // true
//  toString()返回对象的字符串表示
console.log(student.toString()); // [object Object]
// valueOf()返回对象对应的字符串、数值或布尔值表示。通常与toString()的返回值相同。
console.log(student.valueOf()); // { name: 'xiao ming', sex: 'f' }
